<template>
    <div class="reckon">
        <div  @click='substrict'>-</div>
        <div v-text="count"></div>
        <div  @click='add'>+</div>
    </div>
</template>

<script>    
    import {updata} from '../../kits/localSG.js';
    export default{
        props:['number','goodsid'],
        data(){
            return{
                count:1,
                id:0
            }
        },
        created(){
            this.count = this.number;
            this.id = this.goodsid;
        },
        methods:{
            add(){
                this.count++;
                updata({'goodsid':this.id,'count':this.count})
            },
            substrict(){
                this.count--;
                if(this.count<1){
                    this.count = 1;
                }
                updata({'goodsid':this.id,'count':this.count})
            }
        }
    }

</script>

<style scoped>
    .reckon{
        display: inline-block;
    }
    .reckon div{
        text-align: center;
        line-height: 20px;
        display: inline-block;
        width: 40px;
        height: 20px;
        border-radius: 5px;
        border: 1px solid gray;
        font-size: 12px;
        color: rgb(20, 20, 20);
    }

</style>